#include "Function/Acquest.h"
#include "Device/DS18B20.h" 
#include "Device/PCF8591.h"
#include "Device/HCSR04.h"

void AcquestInit()
{
	//设备需要初始化,模块入口处加入设备的初始化函数
	DS18B20_Init();
	PCF8591_Init();
	
	//调用一次
	AcquestGetDistance();
	AcquestGetPhotoCell();
}

float AcquestGetTemperature()
{
	VAR float t=DS18B20_GetCelsius();  
	return t;
}

uint8 AcquestGetPhotoCell()
{
	VAR byte dat;
	if(ADRead(2,&dat))
	{
		return dat;
	}
	return 0U;
}

float AcquestGetDistance()
{
	return HCSR04_GetDistance();
}

/*
float AcquestGetVoltage()
{
	VAR byte dat;
	if(ADRead(0,&dat))
	{
		//计算公式
		//Vlsb=(Vref-Vagnd)/256;
		//Vout=(Vain-Vagnd)/Vlsb;
		//Vagnd=0;
		return dat*0.01953125f+0.0f; 
	}
	return 0.0f;
}*/